import sys
import pygame
import random
from pygame.locals import *

class SkierClass(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.direction = 0 #-2 -1 0 1 2
        self.imgs = ['./images/skier_forward.png',
                     './images/skier_right1.png', 
                     './images/skier_right2.png', 
                     './images/skier_left2.png', 
                     './images/skier_left1.png']
        self.person = pygame.image.load(self.imgs[self.direction])
        self.rect = self.person.get_rect()
        self.rect.center=[320,100]
        self.speed = [self.direction,6-abs(self.direction)*2]


def Show_Start(screen,width,height):
    screen.fill((255, 255, 255))
    cfont = pygame.font.Font('./font/simkai.ttf', width//20)
    #滑雪游戏文字
    title = cfont.render(u'滑雪游戏', True, (255, 0, 0))
    trect = title.get_rect()
    trect.midtop = (width/2, height/10)
    #按任意键继续
    title2 = cfont.render(u'按任意键继续', True, (0, 0, 255))
    trect2 = title2.get_rect()
    trect2.midtop = (width/2, height/5)

    screen.blit(title, trect)
    screen.blit(title2, trect2)
    pygame.display.update()
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == pygame.KEYDOWN:
                return

def main():
    pygame.init()
    # 屏幕
    width = 640
    height = 640
    screen = pygame.display.set_mode([width, height])
    pygame.display.set_caption('滑雪游戏')
    Show_Start(screen,width,height)
    clock = pygame.time.Clock()
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
        pygame.display.flip()
        clock.tick(40)


main()




